home *** CD-ROM | disk | FTP | other *** search
- #include <string.h> /* pour les gestions de strings */
- #include <stdio.h> /* pour printf et les fichiers */
- #include <io.h> /* pour filelenght et eof */
- #include <dos.h> /* pour getdfree */
- #include <stdlib.h> /* pour exit */
-
- char *destname (char *name) {
- char *buf = " " ;
- strcpy (buf, name) ;
-
- buf[strlen(buf)-3] = 77 ; /* change the 3 last chars into "MOD" */
- buf[strlen(buf)-2] = 79 ;
- buf[strlen(buf)-1] = 68 ;
-
- if (strcmp (buf, name) == 0 ) /* if ext. was already MOD, change 1st char*/
- memmove (buf, "_", 1) ;
-
- return buf;
- }
-
-
- int main (int nbparam, char *param[] ) {
- FILE *src, *dest ;
- char *filename = " " ;
- unsigned char buf1 [469], buf2 [129] , buf3 [32000] ;
- int i=0,j=0,s ;
-
- printf ("\nMOD 4 CH 31 INSTR to 15 INSTR converter v12\n") ;
- printf ("Coded by Magic Fred of TFL-TDV \n \n") ;
- if (nbparam != 2) {
- printf ("Syntax: 3115 <filename> \n \n") ;
- printf ("This unuseful util converts a ProTracker/NoiseTracker \n") ;
- printf ("module into an old SoundTracker (15samples) module... \n") ;
- exit (0) ;
- }
-
- filename = param [1] ;
- /* Convert filename to upper case */
- for ( i=0; i<strlen(filename); i++)
- filename [i] = toupper (filename [i]) ;
-
- if (strcmp (destname(filename), filename) == 0) {
- printf("I don't want to convert a MOD file ") ;
- printf("with a name beginning by '_'. Sorry ! \n") ;
- printf("Please rename mod file as *.NST before converting. \n") ;
- exit (1) ;
- }
-
- if ((src=fopen(filename,"rb")) == NULL) {
- printf ("File '%s' not found in current directory.\n",filename) ;
- printf ("Type 3115 without any parameter for help\n \n");
- exit (1) ;
- }
- if ((dest=fopen(destname(filename),"wb")) == NULL) {
- printf ("Cannot open destination file. \n \n") ;
- exit (1) ;
- }
-
-
- /* Convertion : */
-
- for ( i=0 ; i<470 ; i++ ) {
- buf1 [i] = getc (src) ;
- if (feof(src) != 0) {
- printf ("Too early eof error -Is this an Amiga module ? \n \n") ;
- exit (1) ;
- } }
- fseek(src,950,SEEK_SET);
- for ( i=0 ; i<130 ; i++ ) {
- buf2 [i] = getc (src) ;
- if (feof(src) != 0) {
- printf ("Too early eof error -Is this an Amiga module ? \n \n") ;
- exit (1) ;
- } }
-
- for ( i=0 ; i<470 ; i++ )
- putc ( buf1 [i] , dest ) ;
- for ( i=0 ; i<130 ; i++ )
- putc ( buf2 [i] , dest ) ;
-
-
- fseek(src,1084,SEEK_SET);
- while (feof(src) == 0) {
- buf3 [j] = getc(src) ;
- j++ ;
- if (j == 32000) {
- for (i=0 ; i<32000 ; i++) putc (buf3 [i] , dest) ;
- j = 0 ;
- }
- }
- for (i=0 ; i<=j ; i++)
- putc (buf3 [i] , dest) ;
-
- printf("Converted module is '%s'.\n\n",destname(filename)) ;
-
- return 0 ;
- }